﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PServiceBus.Gateway.Interfaces.DTO {
    public class TopicInfo {
        public Guid ID { get; set; }
        public string Name { get; set; }
        public string Filter { get; set; }
        public bool NeedHeader { get; set; }
        public bool IsValid { get; set; }
        public Dictionary<string, string> Contract { get; set; }
        public Dictionary<string, string> Headers { get; set; }
        public List<Dictionary<string, object>> PublishDicts { get; set; }
        public string Description { get; set; }
        public TimeSpan? ExpiresIn { get; set; }
        public bool CaseSensitive { get; set; }

        public TopicInfo() {
            Headers = new Dictionary<string, string>();
            PublishDicts = new List<Dictionary<string, object>>();
            Contract = new Dictionary<string, string>();
        }

        public static TopicInfo New(string name, Guid id, string filter, bool needHeader, string description, Dictionary<string, string> contract) {
            var topic = new TopicInfo();
            topic.Name = name;
            topic.ID = id;
            topic.Filter = filter;
            topic.NeedHeader = needHeader;
            topic.Description = description;
            topic.Contract = contract ?? new Dictionary<string, string>();
            topic.IsValid = true;
            return topic;
        }
    }
}
